package yehang;


import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class CodeGenerator {

    public static void main(String[] args) {

        String url="jdbc:mysql://47.97.21.216:7500/social_network?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT&useSSL=false";
        String username="root";
        String password="root";
        FastAutoGenerator.create(url, username, password)
                .globalConfig(builder -> {
                    builder.author("叶航") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("E:\\Desktop\\demo\\src\\main\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("yehang") // 设置父包名
                            //.moduleName("system") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "E:\\Desktop\\demo\\src\\main\\resources\\mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("t_comment")// 设置需要生成的表名
                            .addInclude("t_comment_like")
                            .addInclude("t_favorite")
                            .addInclude("t_follow")
                            .addInclude("t_image")
                            .addInclude("t_message")
                            .addInclude("t_post_like")
                            .addInclude("t_session")
                            .addInclude("t_setting")
                            .addInclude("t_tip_off")
                            .addInclude("t_university")
                            .addInclude("t_user")



                            .addTablePrefix("t_", "c_"); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();

    }


}

